// 云函数入口文件
const cloud = require("wx-server-sdk");

cloud.init({
  env: cloud.DYNAMIC_CURRENT_ENV,
});

// 云函数入口函数
exports.main = async (event, context) => {
  try {
    console.log("测试环境变量配置");

    const accessKeyId = process.env.ALIYUN_ACCESS_KEY_ID;
    const accessKeySecret = process.env.ALIYUN_ACCESS_KEY_SECRET;

    return {
      code: 0,
      message: "环境变量检查完成",
      data: {
        hasAccessKeyId: !!accessKeyId,
        hasAccessKeySecret: !!accessKeySecret,
        accessKeyIdLength: accessKeyId ? accessKeyId.length : 0,
        accessKeySecretLength: accessKeySecret ? accessKeySecret.length : 0,
      },
    };
  } catch (error) {
    console.error("环境变量检查失败:", error);
    return {
      code: 500,
      message: `环境变量检查失败: ${error.message}`,
      data: null,
    };
  }
};
